import request from '@/utils/request'

// 获取所有的部门信息
export function getDepartments() {
  return request({
    url: '/company/department',
    method: 'GET'
  })
}

// 添加新部门
// data: {code, introduce, manager, name, pid}
export function addDepartments(data) {
  return request({
    url: '/company/department',
    method: 'POST',
    // 'data': data
    data
  })
}

// 根据ID查询部门详情
// id: 部门ID
export function getDepartmentById(id) {
  return request({
    url: '/company/department/' + id,
    method: 'GET'
  })
}

// 修改部门
// data: {id, code, introduce, manager, name, pid}
export function editDepartments(data) {
  return request({
    url: '/company/department/' + data.id,
    method: 'PUT',
    data
  })
}

// 根据ID删除部门
export function delDepartments(id) {
  return request({
    url: '/company/department/' + id,
    method: 'DELETE'
  })
}

// method:
// - get    : 查询/获取
// - post   : 添加
// - put    : 修改
// - delete : 删除
